import React from 'react';
import {useDispatch} from "react-redux";
import {getWeiboAsync, useGetSelectors} from "../store/slice/weibo";

function PageList(props) {
    const dispatch = useDispatch()
    const {pageNo,pageSum,pageSize} = useGetSelectors()
    const pageArr = []
    for(let i = 1;i<=pageSum;i++){
        pageArr.push(<a key={i} href="" onClick={
            e=>{
                e.preventDefault()
                dispatch(getWeiboAsync(i,pageSize))
            }
        } className={pageNo===i? "active":''}>{i}</a>)
    }
    return (
        <div className="page">
            {
                pageArr
            }
        </div>
    );
}

export default PageList;